#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: liang kang
@contact: gangkanli1219@163.com
@desc: 
"""
import argparse

from dltools.utils.log import get_console_logger

from utils.file_read import GoodsReader
from items.data.create_origin_tf_record import OriginRecordGenerator


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--root', type=str, default='', dest='root',
        help='The directory where the image data and the annotation is stored.'
             '保存图像与标记数据的根目录, 图像与其相应标记应当在同一级目录。')
    parser.add_argument(
        '--output', type=str, default='', dest='output',
        help='the root for all the output.'
             '输出结果的根目录')
    parser.add_argument(
        '--use-da', type=bool, default=True, dest='da',
        help='the root for all the output.'
             '输出结果的根目录')
    parser.add_argument(
        '--type', type=str, default='origin', dest='type',
        choices=['origin', 'multi'],
        help='处理数据的方式：数据增强方式')
    parser.add_argument(
        '--class-type', type=str, default='', dest='cls',
        choices=['tow', 'single'],
        help='处理数据的方式：分类方式')
    return parser.parse_args()


def origin_data_generate():
    recorder = OriginRecordGenerator(reader, ARGS.output, ARGS.da, logger,
                                     ARGS.cls)
    recorder.update()


def multi_data_generate():
    pass


if __name__ == '__main__':
    ARGS = parse_args()
    logger = get_console_logger('DataCreator')
    reader = GoodsReader(ARGS.root, logger)
    if ARGS.type == 'origin':
        origin_data_generate()
    elif ARGS.type == 'multi':
        multi_data_generate()
    else:
        raise ValueError()
